<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <title>Far发现你热爱的电影和演员</title>

    <!-- Font Awesome Icons -->
    <link rel="stylesheet" href="/static/plugins/fontawesome-free/css/all.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/static/dist/css/adminlte.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- overlayScrollbars -->
    <link rel="stylesheet" href="/static/dist/css/adminlte.min.css">
    <!-- Google Font: Source Sans Pro -->
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
    <!-- Select2 -->
    <link rel="stylesheet" href="/static/plugins/select2/css/select2.min.css">
    <link rel="stylesheet" href="/static/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">

    <!-- Navbar -->
    <nav class="main-header navbar navbar-expand navbar-white navbar-light">
        <!-- Left navbar links -->
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
            </li>
            <li class="nav-item d-none d-sm-inline-block">
                <a href="index3.html" class="nav-link">首页</a>
            </li>
            <li class="nav-item d-none d-sm-inline-block">
                <a href="#" class="nav-link">联系人</a>
            </li>
        </ul>

        <!-- Right navbar links -->
        <ul class="navbar-nav ml-auto">
            <!-- Messages Dropdown Menu -->
            <li class="nav-item dropdown">
                <a class="nav-link" data-toggle="dropdown" href="">
                    <i class="far fa-user"></i>
                    <span class="badge badge-primary navbar-badge">2</span>
                </a>
                <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
                    <span class="dropdown-header">个人信息</span>
                    <div class="col-md-12">
                        <!-- Widget: user widget style 2 -->
                        <div class="card card-widget widget-user-2">
                            <!-- Add the bg color to the header using any of the bg-* classes -->
                            <div class="widget-user-header bg-warning">
                                <div class="widget-user-image">
                                    <img class="img-circle elevation-2" src="{{ Session.userimage }}" alt="User Avatar">
                                </div>
                                <!-- /.widget-user-image -->
                                <h3 class="widget-user-username">{{ session.username }}</h3>
                                <h5 class="widget-user-desc">{{ session.userdesc }}</h5>
                            </div>
                            <div class="card-footer p-0">
                                <ul class="nav flex-column">
                                    <li class="nav-item">
                                        <a class="nav-link">
                                            ID <span class="float-right badge bg-primary">{{ session.userid }}</span>
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link">
                                            性别 <span class="float-right badge bg-danger">{{ session.usergender }}</span>
                                        </a>
                                    </li>
                                    <li class="nav-item">
                                        <a class="nav-link">
                                            邮箱 <span class="float-right badge bg-info">{{ session.useremail }}</span>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <!-- /.widget-user -->
                    </div>
                    <div class="dropdown-divider"></div>
                    <a href="{{ url_for('account.logout') }}" class="dropdown-item dropdown-footer">退出登录</a>
                </div>
            </li>
        </ul>
    </nav>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <aside class="main-sidebar sidebar-dark-primary elevation-4">
        <!-- Brand Logo -->
        <a href="{{ url_for('actor.start') }}" class="brand-link">
            <img src="/static/dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
                 style="opacity: .8">
            <span class="brand-text ">电影演员分析推荐</span>
        </a>

        <!-- Sidebar -->
        <div class="sidebar">
            <!-- Sidebar user panel (optional) -->
            <div class="user-panel mt-3 pb-3 mb-3 d-flex">
                <div class="image">
                    <img src="{{ Session.userimage }}" class="img-circle elevation-2" alt="User Image">
                </div>
                <div class="info">
                    <a href="#" class="d-block">{{ Session.username }}</a>
                </div>
            </div>

            <!-- Sidebar Menu -->
            <nav class="mt-2">
                <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu"
                    data-accordion="false">
                    <!-- Add icons to the links using the .nav-icon class
                         with font-awesome or any other icon font library -->
                    <li class="nav-item has-treeview menu-open">
                        <a class="nav-link active">
                            <i class="nav-icon fas fa-tachometer-alt"></i>
                            <p>
                                功能菜单
                                <i class="right fas fa-angle-left"></i>
                            </p>
                        </a>
                        <ul class="nav nav-treeview">
                            <li class="nav-item">
                                <a href="{{ url_for('actor.start') }}" class="nav-link">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>演员列表</p>
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="{{ url_for('film.start') }}" class="nav-link active">
                                    <i class="far fa-circle nav-icon"></i>
                                    <p>电影列表</p>
                                </a>
                            </li>
                        </ul>
                    </li>
                    <li class="nav-item">
                        <a href="{{ url_for('recommend.start') }}" class="nav-link">
                            <i class="nav-icon fas fa-th"></i>
                            <p>
                                演员推荐
                                <span class="right badge badge-danger">Hot</span>
                            </p>
                        </a>
                    </li>
                </ul>
            </nav>
            <!-- /.sidebar-menu -->
        </div>
        <!-- /.sidebar -->
    </aside>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">电影列表</h1>
                    </div><!-- /.col -->
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">首页</a></li>
                            <li class="breadcrumb-item active">电影列表</li>
                        </ol>
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content-header -->

        <!-- Main content -->
        <div class="content">
            <div class="container-fluid">
                <!-- Default box -->
                <div class="row">
                    <div class="col-md-3">
                        <div class="form-group">
                            <label>电影种类</label>
                            <div class="select2-blue">
                                <select id="typeSelect" class="select2" multiple="multiple" data-placeholder="选择电影类型"
                                        style="width: 100%;">
                                    <option>剧情 </option>
                                    <option>爱情 </option>
                                    <option>动作 </option>
                                    <option>科幻 </option>
                                    <option>冒险 </option>
                                    <option>悬疑 </option>
                                    <option>喜剧 </option>
                                    <option>惊悚 </option>
                                    <option>传记 </option>
                                    <option>动画 </option>
                                    <option>家庭 </option>
                                    <option>奇幻 </option>
                                    <option>武侠 </option>
                                    <option>灾难 </option>
                                    <option>歌舞 </option>
                                    <option>历史 </option>
                                    <option>音乐 </option>
                                    <option>短片 </option>
                                    <option>儿童 </option>
                                    <option>古装 </option>
                                    <option>恐怖 </option>
                                    <option>情色 </option>
                                    <option>同性 </option>
                                    <option>戏曲 </option>
                                    <option>犯罪 </option>
                                    <option>战争 </option>
                                    <option>西部 </option>
                                    <option>运动 </option>
                                    <option>真人秀 </option>
                                    <option>纪录片 </option>
                                    <option>脱口秀 </option>
                                </select>
                            </div>

                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label>电影年份</label>
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="far fa-clock"></i></span>
                                </div>
                                <input type="text" class="form-control float-right" id="timeSearch"
                                       value="{{ film_year }}">
                            </div>
                            <!-- /.input group -->
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <label>电影信息</label>
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text"><i class="far fa-pager"></i></span>
                                </div>
                                <input id="filmSearchContent" class="form-control float-right" type="text"
                                       placeholder="搜索电影名称、演员姓名..." aria-label="Search" value="{{ search }}">
                                <div class="input-group-append">
                                    <button class="btn btn-sm btn-primary" onclick="searchFilm();">
                                        <i class="fas fa-search">搜索</i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3">
                        <!-- radio -->
                        <div class="form-group">
                            <label>排序</label>
                            <div class="row">
                                <div class="custom-control custom-radio col-md-5">
                                    <input class="custom-control-input" type="radio" id="customRadio1" value="film_year"
                                           name="customRadioSort"
                                           checked="">
                                    <label for="customRadio1" class="custom-control-label">年份降序</label>
                                </div>
                                <div class="col-md-2"></div>
                                <div class="custom-control custom-radio col-md-5">
                                    <input class="custom-control-input" type="radio" id="customRadio2"
                                           name="customRadioSort" value="film_score">
                                    <label for="customRadio2" class="custom-control-label">评分降序</label>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
                <br>
                <div class="card card-solid">
                    <div class="card-body pb-0">
                        <div class="row d-flex align-items-stretch">
                            {% for film in Films.items %}
                                <div class="col-12 col-sm-4 col-md-4 d-flex align-items-stretch">
                                    <div class="card bg-light">
                                        <div class="card-header text-muted border-bottom-0">
                                            {{ film.film_year }}
                                        </div>
                                        <div class="card-body pt-0">
                                            <div class="row">
                                                <div class="col-5 text-center">
                                                    <img src="/static/image/film/{{ film.film_img }}" alt=""
                                                         class="img-rounded img-fluid">
                                                </div>
                                                <div class="col-7">
                                                    <h2 class="lead"><b>{{ film.film_name }}</b></h2>
                                                    <p class="text-muted text-sm">
                                                        <b>主演: </b>
                                                        {{ film.film_protagonist }}
                                                    </p>
                                                    <p class="text-muted text-sm">
                                                        <b>电影类型: </b> {{ film.film_type }}
                                                    </p>

                                                </div>

                                            </div>
                                        </div>
                                        <div class="card-footer">
                                            <div class="text-right">
                                                <a class="btn-lg">
                                                    <i style="color:black;font-size: xx-large">{{ film.film_score }}</i>
                                                </a>
                                                <a id="moreFilmButton{{ film.film_id }}"
                                                   class="btn btn-sm btn-primary"
                                                   onclick="showFilmMore(this);">
                                                    <i class="fas fa-user"
                                                       style="color:white;font-size: small">查看更多</i>
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            {% endfor %}
                        </div>
                    </div>
                    <!-- /.card-body -->

                    <div class="card-footer">
                        <nav aria-label="Contacts Page Navigation">
                            <ul class="pagination justify-content-center m-0">
                                {% for page in Films.iter_pages() %}
                                    {% if page %}
                                        {% if page !=Films.page %}
                                            <li class="page-item"><a class="page-link"
                                                                     href="{{ url_for('film.start',page=page, film_year=film_year, film_type=film_type, search=search,sorted_by=value) }}">{{ page }}</a>
                                            </li>
                                        {% else %}
                                            <li class="page-item active"><a class="page-link"
                                                                            href="#">{{ Films.page }}</a></li>
                                        {% endif %}
                                    {% endif %}
                                {% endfor %}


                            </ul>
                        </nav>
                    </div>
                    <!-- /.card-footer -->
                </div>
                <!-- /.card -->
            </div><!-- /.container-fluid -->
        </div>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
        <div class="p-3">
            <h5>Title</h5>
            <p>Sidebar content</p>
        </div>
    </aside>
    <!-- /.control-sidebar -->

    <!-- Main Footer -->
    <footer class="main-footer">
        <!-- To the right -->
        <div class="float-right d-none d-sm-inline">
            Far 电影演员分析推荐系统
        </div>
        <!-- Default to the left -->
        <strong>Copyright <a href="https://github.com/HunterLC">HunterLC</a>.</strong> All rights reserved.
    </footer>
</div>
<!-- ./wrapper -->

<!-- REQUIRED SCRIPTS -->

<!-- jQuery -->
<script src="/static/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="/static/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="/static/dist/js/adminlte.min.js"></script>
<!-- Select2 -->
<script src="/static/plugins/select2/js/select2.full.min.js"></script>
<script>
    function searchFilm() {
        let typeSelect = $("#typeSelect option:selected").text(); //电影类型
        let timeSelect = $("#timeSearch").val();//电影上映时间
        let inputContent = $("#filmSearchContent").val();//搜索内容
        let radioSelect = document.getElementsByName("customRadioSort");
        var value = "";
        for(var i=0;i<radioSelect.length;i++){
                if(radioSelect[i].checked === true){
                    value = radioSelect[i].value;
                    break;
                }
            }
        window.location.href = "{{ url_for('film.start') }}" + "?film_type=" + typeSelect + "&film_year=" + timeSelect + "&search=" + inputContent + "&sorted_by=" + value;
    }
</script>
<script>
    function showFilmMore(self) {
        console.log(self.id);
        window.location.href = "{{ url_for('film.get_film_info') }}" + "?film_id=" + self.id;
    }
</script>
<script>
    $(function () {
        //Initialize Select2 Elements
        $('.select2').select2();
        //Initialize Select2 Elements
        $('.select2bs4').select2({
            theme: 'bootstrap4'
        });
        $("#typeSelect option").each(function () {
            let txt = $(this).text();
            str = "{{ film_type }}" + " ";
            if (str.search(txt) !== -1) {
                $(this).attr("selected", "selected")
            }
        });
        let radioSelect = document.getElementsByName("customRadioSort");
        for(var i=0;i<radioSelect.length;i++){
                if(radioSelect[i].value === "{{ value }}"){
                    radioSelect[i].checked = true;
                    break;
                }else{
                    radioSelect[i].checked = false;
                }
        }
    })
</script>
</body>
</html>
